﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Principal;
using System.Text;


namespace Framework.Core
{
    /// <summary>
    /// 用户。
    /// </summary>
    [DataContract]
    [Serializable]
    public class User : IIdentity
    {
        #region Properties

        /// <summary>
        /// 是否经过验证
        /// </summary>
        public bool IsAuthenticated { get; set; }

        /// <summary>
        /// 移动电话
        /// </summary>
        [DataMember]
        public string Mobile { get; set; }

        /// <summary>
        /// 电子邮件
        /// </summary>
        [DataMember]
        public string Email { get; set; }

        /// <summary>
        /// 是否有效
        /// </summary>
        [DataMember]
        public bool IsValid { get; set; }

        /// <summary>
        /// 雇员姓名
        /// </summary>
        [DataMember]
        public string EmployeeName { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        [DataMember]
        public string Name { get; set; }

        /// <summary>
        /// 员工卡号
        /// </summary>
        [DataMember]
        public string EmployeeCardNumber { get; set; }

        /// <summary>
        /// 用户ID
        /// </summary>
        [DataMember]
        public string Id { get; set; }

        /// <summary>
        /// 存放从session取user对象的id
        /// </summary>
        public int SessionId { get; set; }

        /// <summary>
        /// 用户密码
        /// </summary>
        [DataMember]
        public string Password { get; set; }

        /// <summary>
        /// 密码过期日期
        /// </summary>
        public DateTime PasswordExpireDate { get; set; }

        /// <summary>
        /// 所属酒店公司
        /// </summary>
        public HotelOrg HotelOrg { get; set; }

        /// <summary>
        /// 所属部门
        /// </summary>
        public string Department { get; set; }

        /// <summary>
        /// 职务
        /// </summary>
        public string Position { get; set; }

        /// <summary>
        /// 用户角色
        /// </summary>
        public List<RoleInfo> Roles { get; set; }

        /// <summary>
        /// 登录默认酒店
        /// </summary>
        public string DefaultHotelId { get; set; }

        /// <summary>
        /// 实际登录酒店
        /// </summary>
        public string LoginHotelId { get; set; }


        /// <summary>
        /// 实际登录酒店
        /// </summary>
        public List<UserAuth> UserAuths { get; set; }
        ///// <summary>
        ///// 角色集合
        ///// </summary>
        //public Dictionary<string, List<OrganizationScope>> Roles
        //{
        //    get;
        //    set;
        //}

        //public List<Credential> Credentials
        //{
        //    get;
        //    set;
        //}

        #endregion

        public User()
        {
        }

        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append(base.ToString()).Append("\r\n");
            sb.Append("ID:").Append(Id).Append("\r\n");
            sb.Append("Name:").Append(Name).Append("\r\n");
            sb.Append("IsAuthenticated:").Append(IsAuthenticated);

            return sb.ToString();
        }

        #region IIdentity 成员

        public string AuthenticationType
        {
            get { return " Authentication"; }
        }

        #endregion


        //private Int64 _roleToken = int.MinValue;

       
    }
}
